<?php
$this->breadcrumbs=array(
	'Monitoring',
);

$menuAdmin=array(
	array('label'=>Yii::t('view', 'Monitoring'),'url'=>array('index'),'icon'=>'fa fa-list-alt', 'items' =>
		array(	
			array('label'=>Yii::t('view', 'Create Checkpoint'),'url'=>array('monitoring/create'),'icon'=>'fa fa-plus-square'),
			array('label'=>Yii::t('view', 'List Checkpoint'),'url'=>array('viewcheckpoint/'),'icon'=>'fa fa-tasks'),
                        array('label'=>Yii::t('view', 'Export Monitoring'),'url'=>array('viewmonitoring/export'),'icon'=>'fa fa-print','visible'=>Yii::app()->user->isAdmin()),
		)
	)	
);

$menu=array(
           array('label'=>Yii::t('view', 'List Checkpoint'),'url'=>array('viewcheckpoint/'),'icon'=>'fa fa-list-ol'),
);
$this->menu = (Yii::app()->user->isAdmin() || Yii::app()->user->isWeigher()) ? $menuAdmin : $menu ;
Yii::app()->clientScript->registerScript('search', "
	$('.search-button').click(function(){
		$('.search-form').toggle();
		return false;
	});
	$('.search-form form').submit(function(){
		$.fn.yiiGridView.update('view-checkpoint-grid', {
			data: $(this).serialize()
		});
		return false;
	});
");
?>

<?php $box = $this->beginWidget(
    'bootstrap.widgets.TbBox',
    array(
        'title' =>Yii::t('view', 'List Monitoring'),
        'headerIcon' => 'icon- fa fa-list-ol',
        'headerButtons' => array(
            array(
                'class' => 'bootstrap.widgets.TbButtonGroup',
                'type' => 'success',
                // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
                'buttons' => $this->menu
            ),
        ) 
    )
);?>
		<?php $this->widget('bootstrap.widgets.TbAlert', array(
		    'block'=>false, // display a larger alert block?
		    'fade'=>true, // use transitions?
		    'closeText'=>'&times;', // close link text - if set to false, no close link is displayed
		    'alerts'=>array( // configurations per alert type
		        'success'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'info'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'warning'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'error'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'danger'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		    ),
		));
		?>

<?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'view-checkpoint-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
//        'ajaxUpdate' => 'js:function(){return $.fn.yiiGridView.update()}',
	'type' => 'striped hover bordered condensed',
	'columns'=>array(
		array('header'=>'#','value'=>'($this->grid->dataProvider->pagination->currentPage*
					 $this->grid->dataProvider->pagination->pageSize
					)+
					array_search($data,$this->grid->dataProvider->getData())+1',
				'htmlOptions' => array('style' =>'width: 15px'),
		),
		array(
                    'header' => '',
                    'name' => 'status',
                    'type' => 'raw',
                    'filter' => false,
                    'value' =>array($this, 'getStatus'),
                ),
		array(
                    'header' =>Yii::t('view', 'Tiket'),
                    'name' => 'noTiket',
                    'type' => 'raw',
                    'value' => '($data->noTiket)',
                    'filter' =>CHtml::activeTextField($model, 'noTiket', array('autofocus' => 'autofocus')),
                ),
		array(
                    'header' =>Yii::t('view', 'Tanggal'),
                    'name' => 'timbanganMasuk',
                    'type' => 'raw',
                    'value' => 'date("d-m-Y",strtotime($data->timbanganMasuk))',
                ),
		'noDokumen',
		array(
                    'header' =>Yii::t('view', 'Status'),
                    'name' => 'statusMobil',
                    'type' => 'raw',
                    'value' => '($data->statusMobil)',
                ),
                'noPolisi',
		array(
                    'header' =>Yii::t('view', 'Masuk Timbangan'),
                    'name' => 'timbanganMasuk',
                    'type' => 'raw',
                    'value' => 'date("H:i:s",strtotime($data->timbanganMasuk))',
                ),
		array(
                	'name' => 'waktuParkir',
                    'type' => 'raw',
                    'value' => 'date("H:i:s",strtotime($data->waktuParkir))',
                ),
		array(
                    'header' =>Yii::t('view', 'Masuk Gudang'),
                    'name' => 'waktuMulai',
                    'type' => 'raw',
                    'value' => 'date("H:i:s",strtotime($data->waktuMulai))',
                ),
		array(
                    'header' =>Yii::t('view', 'Keluar Gudang'),
                    'name' => 'waktuSelesai',
                    'type' => 'raw',
                    'value' => 'date("H:i:s",strtotime($data->waktuSelesai))',
                ),
		array(
                    'header' =>Yii::t('view', 'Keluar Timbangan'),
                    'name' => 'timbanganKeluar',
                    'type' => 'raw',
                    'value' => 'date("H:i:s",strtotime($data->timbanganKeluar))',
                ),
		array(
			'class'=>'bootstrap.widgets.TbButtonColumn',
			'template'=>'{info} {delete}',
                        'htmlOptions' => array('style' =>'width: 61px;text-align:center'),
                        'buttons'=>array
                        (
                            'info' => array
                            (
                                'label'=>Yii::t('view','Info Detail'),
                                'icon'=>'fa fa-info',
                                'url'=>'array("viewmonitoring/view","id"=>$data->id)',
                                'options'=>array(
                                    'class'=>'badge badge-info',
                                ),
                            ),
//                            'newtab' => array
//                            (
//                                'label'=>Yii::t('view','Detail Open in New Tab'),
//                                'icon'=>'fa fa-info-circle',
////                                'url'=>'array("kartu/create")',
//                                'options'=>array(
//                                    'class'=>'badge badge-info',
//                                    'onclick'=>'js:window.open("'.Yii::app()->baseUrl.'/kartu/create", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes");'
////                                    'target'=>'_blank',
//                                ),
//                            ),
                            'delete' => array
                            (
                                'label'=>Yii::t('view','Delete'),
                                'icon'=>'fa fa-trash-o',
                                'url'=>'array("monitoring/delete","id"=>$data->id)',
                                'visible'=>'(Yii::app()->user->isAdmin())',
                                'options'=>array(
                                    'class'=>'badge badge-delete',
                                ),
                            ),
                        )
		),
	),
)); ?>

<div class="well well-small">
    Keterangan :
    <br/>
    <span class="label label-success">
       <i class="fa fa-check-square-o"></i>
    </span>&nbsp;Total waktu keluar gudang kurang dari/sama dengan target
    &nbsp;&nbsp;
    <span class="label label-important">
       <i class="fa fa-dot-circle-o"></i>
    </span>&nbsp;Total waktu keluar gudang melebihi target
</div>
<?php $this->endWidget(); ?>